DXL Error

What's the error here? Just discovered it; had this function for 12 years.

bool    fReplaceString(Buffer &in_bufString, string in_FromString, in_ToString, bool in_MatchCase)
{     // Replace all instances of in_FromString to in_ToString in the in_bufString.
        // Return whether a change was actually made
        // When in_MatchCase, in_FromString must match exactly,
        //      otherwise in_FromString may match case-insensitively
        // Notice that less converting/unconverting is used when in_MatchCase is true.
        if (fIsEmptyBuf(in_bufString)   or                      // Program error        -
            null in_FromString          or                      // Program error        -
            in_FromString == in_ToString                        // nothing to do        -
           )                            then return(false)
        // body snipped, no errors there
}


Don't worry about fIsEmptyBuf(), it works.

-Louie


llandale - Wed Aug 08 10:50:14 EDT 2012

Re: DXL Error
Mathias Mamsch - Wed Aug 08 14:55:51 EDT 2012

Well except that you have a buffer reference which could make fIsEmptyBuf fail if it also takes a Buffer reference and contains a null check, I see nothing. Maybe it would help, when you tell us, WHAT error you are experiencing and maybe even though you think you traced the error to the one statement, post an example that demonstrates the error, we could help better. Regards, Mathias

Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: DXL Error
llandale - Thu Aug 09 16:21:03 EDT 2012

When From and To are both "A" and not Matchcase option, it SHOULD turn string "abc" into "Abc". But the From==To check disallows that. Had that for 12 years and never noticed; I think because I don't do case-insensitive searches. Glad to see nobody else noticed right away!